package com.jyniubi.core.controller.admin;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jyniubi.base.result.R;
import com.jyniubi.base.result.ResponseEnum;
import com.jyniubi.core.pojo.entity.Borrower;
import com.jyniubi.core.pojo.vo.ApprovalFormVO;
import com.jyniubi.core.pojo.vo.BorrowerDetailVO;
import com.jyniubi.core.service.BorrowerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 借款人 前端控制器
 * </p>
 *
 * @author jyzhang
 * @since 2024-04-27
 */
@Api(tags = "管理台借款人信息")
@RestController
@RequestMapping("/admin/core/borrower")
public class AdminBorrowerController {

    @Resource
    private BorrowerService borrowerService;

    @ApiOperation("查询借款人列表")
    @GetMapping("/getBorrowerList/{pageNum}/{pageSize}")
    public R getBorrowerList(@PathVariable("pageNum") Integer pageNum,
                             @PathVariable("pageSize") Integer pageSize,
                             String keyword){
        Page<Borrower> borrowerList =  borrowerService.getBorrowerList(pageNum,pageSize,keyword);
        return R.ok().data("page",borrowerList);
    }
    @ApiOperation("查询借款人详情")
    @GetMapping("/details/{id}")
    public R getStatus(@PathVariable("id") String id){
        BorrowerDetailVO borrowerDetailVO = borrowerService.getBorrowerDetailById(id);
        return R.ok().data("item",borrowerDetailVO);
    }

    @ApiOperation("借款人审批")
    @PostMapping("/approval")
    public R approval(@RequestBody ApprovalFormVO approvalFormVO){
        borrowerService.approval(approvalFormVO);
        return R.ok().msg("审批完成");
    }
}

